import http.client, ssl

#   禁用所有的验证
context = ssl._create_unverified_context()
#   与服务器建立连接, 并使用context参数
conn = http.client.HTTPSConnection('localhost', 8443, context=context)
url = '/agileone/'
#   向服务器发起GET请求
conn.request('GET', url)
#   获取响应并解码
response = conn.getresponse().read().decode()
#   打印响应
# print(response)

conn = http.client.HTTPSConnection('localhost', 8443, context=context)
param = 'username=admin&password=admin&savelogin=true'
header = {'Content-Type': 'application/x-www-form-urlencoded', 'Accept': '*/*'}
conn.request('POST', '/agileone/index.php/common/login', param, header)
response = conn.getresponse().read()

print(response.decode())

# context = ssl._create_unverified_context()
# url = 'https://localhost:8443/agileone/'
# r = urllib.request.Request(url)
# response = urllib.request.urlopen(r, context=context).read().decode()
# print(response)
#

import urllib.request, ssl

context = ssl._create_unverified_context()
url = 'https://localhost:8443/agileone/'
r = urllib.request.urlopen(url, context=context)
response = r.read().decode()
# print(response)

param = {'username': 'admin', 'password': 'admin', 'savelogin': 'true'}
response = urllib.request.urlopen(url='https://localhost:8443/agileone/index.php/common/login',
                                  data=urllib.parse.urlencode(param).encode('utf-8'), context=context)
print(response.read().decode())
